﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>梨相续</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="/css/swiper.min.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/layui/css/layui.css"  media="all">
<link rel="stylesheet" type="text/css" href="/front-index/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/front-index/css/index.css" />
<script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/swiper.min.js"></script>
<script type="text/javascript" src="/js/custom.js"></script>
<script type="text/javascript" src="/js/layui-post.js"></script>
</head>
<body class="PB50">
<div class="index_header">
    <div id="mainMenuBarAnchor"></div>
    <div class="header_top" id="mainMenuBar">
        <div class="search" onclick="window.location.href='/search'">
            <label for="search"></label>
            <input id="search" type="text" placeholder="搜索您要的商品" />
            <input type="submit" value="搜索" />
        </div>
        <div class="message">
            <a href="#">
                <span>0</span>
            </a>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function() {
            var $window = $(window),$mainMenuBar = $('#mainMenuBar'),$mainMenuBarAnchor = $('#mainMenuBarAnchor');
            $window.scroll(function() {
                var window_top = $window.scrollTop();
                var div_top = $mainMenuBarAnchor.offset().top;
                if (window_top > div_top) {
                    $mainMenuBar.addClass('stick');
                    $mainMenuBarAnchor.height($mainMenuBar.outerHeight());
                } else {
                    $mainMenuBar.removeClass('stick');
                    $mainMenuBarAnchor.height(0);
                }
            });
        });
    </script>
    <div class="header_bottom">
        <div class="swiper-container banner">
            <div class="swiper-wrapper" id="slideImgItem"></div>
            <div class="swiper-pagination"></div>
        </div>
    </div>
</div>
<div class="user">
    <img class="touxiang" src="/front-index/picture/touxiang.png" />
    <div class="info">
        <h2 class="niki"></h2>
        <ul class="list">
            <a class="item" href="/shop">
                <p class="pic">
                    <img src="/front-index/images/ico_1.png" />
                </p>
                <span class="title">全部商品</span>
            </a>
            <a class="item" href="/shop">
                <p class="pic">
                    <img src="/front-index/images/ico_2.png" />
                </p>
                <span class="title">最新商品</span>
            </a>
            <a class="item" href="/order">
                <p class="pic">
                    <img src="/front-index/images/ico_3.png" />
                </p>
                <span class="title">我的订单</span>
            </a>
            <a class="item" href="/points">
                <p class="pic">
                    <img src="/front-index/images/ico_4.png" />
                </p>
                <span class="title">我的积分</span>
            </a>
        </ul>
    </div>
</div>
<!-- 模块 -->
<div class="mukuai">
    <ul class="list index_menu"></ul>
</div>
<div class="mukuai1">
    <ul class="list">
        <a href="#" class="item item1">
            <h3 class="title">限时秒杀</h3>
            <div class="pic">
                <img src="/front-index/picture/huo.png" />
                <img src="/front-index/picture/huo.png" />
                <img src="/front-index/picture/dian.png" />
            </div>
            <div class="word">暂未开放</div>
        </a>
        <a href="/groupindex?type=1" class="item item2">
            <h3 class="title">热门团购</h3>
            <div class="tuan">
                <img src="/front-index/picture/tuan.png" />
                <div class="content">
                    <p>火爆的团购进行中</p>
                    <span>1000+评价</span>
                </div>
            </div>
            <div class="word">万人推荐</div>
        </a>
    </ul>
</div>

<div class="index_pro">
    <div class="item">
        <div class="top">
            <div class="title">
                <a>团购商品</a>
                <span>一件享受团购价</span>
            </div>
        </div>
        <ul class="list tuangougoods"></ul>
    </div>
</div>
<script>
    $('.tabbar ul a').click(function(){
        $(this).parent('li').siblings('li').find('a').removeClass('active');
        $(this).addClass('active');
    });
</script>
</body>
<script type="text/javascript">
$.ajaxSetup({contentType: "application/json; charset=utf-8"});
if(getQueryString("opendId") != null && getQueryString("opendId") != undefined){
    sessionStorage.setItem("opendId", getQueryString("opendId"));
}
var userInfo = sessionStorage.getItem("userInfo");
layui.use(['flow','layer','carousel','util'], function(){
    var loading = layer.load(0, {shade: 0.1});
    layui.util.fixbar({
        top:true,css: { right: 15, bottom: 105 },showHeight:100,
        click: function (type) {if (type === 'top') $('.layui-fluid').animate({scrollTop: 0}, 200);}
    });
    if(isEmpty(userInfo)){
        $.post("/cateringUser/selectOne",JSON.stringify({opendId:sessionStorage.getItem("opendId")}), function (res) {
            if(res.data != null){
                userInfo = res.data;
                sessionStorage.setItem("userInfo", JSON.stringify(res.data));
            }else{
                window.location.href=getHttp()+"/wxpay/catering.html"
            }
        })
    }else{
        userInfo = $.parseJSON(userInfo);
        $(".niki").html(userInfo.nickName)
    }
    getTopGoods()
    getModules()
    if(userInfo.isAdminUser == 1){
        getOrderStatus()
        setInterval(getOrderStatus,30000);
    }
})
function getTopGoods(){
    $("#slideImgItem").empty()
    $(".tuangougoods").empty()
    $.post("/front/cateringGoods/select",JSON.stringify({status:0,isTop:1}), function (res) {
        layer.closeAll()
        for(var i in res.data){
            $("#slideImgItem").append(
                '<div class="swiper-slide" onclick="window.location.href=\'/detail?sysId='+res.data[i].sysId+'\'"><img src="'+res.data[i].goodsImg+'" /></div>'
            )
            $(".tuangougoods").append(
                '<li class="item">' +
                '<div class="pic">' +
                '<a href="/detail?sysId='+res.data[i].sysId+'"><img src="'+res.data[i].goodsImg+'" /></a>' +
                '</div>' +
                '<div class="content">' +
                '<h2 class="title"><a href="#">'+res.data[i].goodsName+'</a></h2>' +
                '<p class="desc">' +
                '<a>招牌</a>' +
                '<a>火爆商品</a>' +
                '<a>'+res.data[i].goodsWeight+'</a>' +
                '</p>' +
                '<p class="tab">' +
                '<a>特卖</a>' +
                '<a>新品</a>' +
                '</p>' +
                '<div class="info">' +
                '<p class="left">' +
                '<strong>￥'+(res.data[i].goodsPrice*res.data[i].discount/10).toFixed(2)+'</strong>' +
                '<span>￥'+res.data[i].goodsPrice+'</span>' +
                '</p>' +
                '<a class="qiang" href="/detail?sysId='+res.data[i].sysId+'">立即抢购</a>' +
                '</div>' +
                '</div>' +
                '</li>'
            )
        }
    }).done(function(){
        var swiper = new Swiper('.banner', {
            pagination: '.banner .swiper-pagination',
            autoplay: 2500,
            paginationClickable: true
        });
    })
}
function getModules(){
    $.post("/cateringModule/select",JSON.stringify({status:0}), function (res) {
        if(res.data.length > 0) $(".index_menu").empty()
        var dispaly = "block"
        for(var i in res.data){
            if(res.data[i].moduleUrl == '/sendpage' && userInfo.isSendUser != 1) dispaly = 'none';
            if(res.data[i].moduleUrl == '/business' && userInfo.isAdminUser != 1) dispaly = 'none';
            $(".index_menu").append(
                '<a href="'+res.data[i].moduleUrl+'" class="item">' +
                '<p class="pic">' +
                '<img src="'+res.data[i].moduleIcon+'" />' +
                '</p>' +
                '<span class="title">'+res.data[i].moduleName+'</span>' +
                '</a>'
            )
        }
    })
}
</script>
<script type="text/javascript" src="/js/bottom-menu.js"></script>
</html>
